package com.example.mqttdemo.controller;
import com.example.mqttdemo.Utils;
import com.example.mqttdemo.mqtt.MqttPushClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
@RestController
@RequestMapping("mqttDemo")
public class MqttDemoController {
    @Autowired
    private MqttPushClient mqttPushClient;
    @RequestMapping("testPublishMessage1")
    public String testPublishMessage() {
        System.out.println("11111111111z1111");
        //bai_topic_pub 因为开发板的发pub对于spring就是sub 所以发送接收名字一致就行
        mqttPushClient.publish("bai_topic_one","看到我就代表通了md");
        System.out.println("666666666");
        ////为什么springboot的项目每发一条信 springboot都能收到
        //为什么浏览器访问之后页面空白呢？因为这个controller没有返回页面 压根没有return
    return "Send Success";
    }

    @RequestMapping("testPublishMessage2")
    public void testPublishMessage2(String message){

        mqttPushClient.publish("test_queue",message);
    }
    @RequestMapping(value = "getStatus")
    public String testPublishMessage3(String message){

        return Utils.statu;
    }

}
